#include <iostream>
#include <set>

using namespace std;

void f1(std::set<int, std::greater<int>>& s)
{
	int i = 0;
	for (auto it = s.begin(); it != s.end(); it = s.upper_bound(i))
		cout << (i = *it) << " ";

	cout << endl;
}

void f2(std::set<int, std::greater<int>>& s)
{
	int i = 0;
	for (auto it = s.begin(); it != s.end(); it = s.lower_bound(i + 1))
		cout << (i = *it) << " ";

	cout << endl;
}

void f3(std::set<int, std::greater<int>>& s)
{
	for (int i = 0; i < 10; ++i)
	{
		cout << "i=" << i << ",";
		auto it = s.upper_bound(i);
		if (it == s.end())
			cout << "Null ";
		else
			cout << *it << " ";
	}

	cout << endl;
}

void f4(std::set<int, std::greater<int>>& s)
{
	for (int i = 0; i < 10; ++i)
	{
		cout << "i=" << i << ",";
		auto it = s.lower_bound(i);
		if (it == s.end())
			cout << "Null";
		else
			cout << *it;

		cout << "\t";
	}

	cout << endl;
}

int main()
{
	std::set<int, std::greater<int>> s1 = { 1, 3, 5, 6, 8 };
	//f1(s1);
	//f2(s1);
	f3(s1);
	f4(s1);
	std::set<int, std::greater<int>> s2 = { 0, 2, 4, 5, 7 };
	//f1(s2);
	//f2(s2);
	f3(s2);
	f4(s2);


	return 0;
}